#include "pch.h"
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
	vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
		int len1 = nums1.size();
		int len2 = nums2.size();
		if (!len1 || !len2) return {};

		vector<int> res;
		int k = 0;
		for (int i = 0;i < len1;i++)
		{
			for (int j = 0;j < len2;j++)
			{
				if (nums2[j] == nums1[i])
				{
					if (find(res.begin(), res.end(), nums2[j]) == res.end())
					{
						res.push_back(nums2[j]);
					}
					break;
				}
			}
		}
		return res;
	}
};

int main()
{
	vector<int> arr1{ 1,2,2,1 };
	vector<int> arr2{ 2,3 };
	vector<int> res;
	Solution s;
	res = s.intersection(arr1,arr2);

	for (auto it = res.begin();it != res.end();it++)
	{
		cout << (*it) << " ";
	}

	return 0;
}